﻿using TestPrint.CommonPrintSet;

namespace TestPrint.PrintNameHelp.PrintControl
{
    public partial class BagPrint : BaseSetting
    {
        private LocalPrint _localPrint;
        private ControlTreeItem<LocalPrint> _settingItem = LocalPrinterSetting.bag;
        public BagPrint()
        {
            InitializeComponent();
            this.cbxInstalledPrinters.Items.AddRange(this.FindPrinters());
            _localPrint = LocalPrinterSetting.GetObject(_settingItem);
            if (_localPrint != null)
                SetData(_localPrint);
        }

        public void GetData()
        {
            _localPrint.Printer = cbxInstalledPrinters.Text;
            _localPrint.PageWith = 827;
            _localPrint.PageHeight = 1169;
        }

        public void SetData(LocalPrint print)
        {
            cbxInstalledPrinters.Text = print.Printer;
        }

        public override void Save()
        {
            GetData();
            LocalPrinterSetting.Save(_settingItem, _localPrint);
        }
    }
}